/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Parallel;

import Parallel.ElementHandler;
import java.io.IOException;

/**
 *
 * @author zwirek
 */
public class ExampleImplemntation implements ElementHandler{
    public double max = Double.MIN_VALUE;
    public int cnt = 0;

    public void onEndParsing(Parallel.Parser parser) {
        double localMax = Double.MIN_VALUE;
        int localCnt=0;
        for(ElementHandler eh : parser.handlers){
            ExampleImplemntation ei = (ExampleImplemntation)eh;
            if(ei.max>localMax){
                localMax = ei.max;
            }
            localCnt+=ei.cnt;
        }
        System.out.println(localCnt+" Max:"+localMax);
    }

    @Override
    public void onStartElement(Parallel.Node n) {
        
    }

    @Override
    public boolean onEndElement(Parallel.Node n) {
        if((new String(n.getName())).equals("LatitudeMeasure")){
            double d = Double.parseDouble(n.getText());
            if(d>max)
                max=d;
            cnt++;
        }
        return false;
    }


}
